package com.dubbo.remote.common;

import com.dubbo.remote.utils.StringUtils;

/**
 * 异常封装
 * @author Mr.老狼
 *
 */
public class BusinessException extends RuntimeException {
	private String code;
	private Object params;
	private String userMsg;
	private static final long serialVersionUID = -6811768910836758978L;

	public BusinessException(String message) {
		super(message);
		this.code = message;
	}

	public BusinessException(String message, String code) {
		this(StringUtils.isEmpty(message) ? code : message);
		this.code = code;
	}

	public BusinessException(String message, String code, Object params) {
		this(StringUtils.isEmpty(message) ? code : message, code);
		this.params = params;
	}

	public BusinessException(String message, String code, Object params,
			String userMsg) {
		this(StringUtils.isEmpty(message) ? code : message, code, params);
		this.userMsg = userMsg;
	}

	public BusinessException(String message, String code, Throwable e) {
		this(StringUtils.isEmpty(message) ? code : message, e);
		this.code = code;
	}

	public BusinessException(String message, Throwable e) {
		super(message, e);
	}

	public String getCode() {
		return code;
	}

	public BusinessException setCode(String code) {
		this.code = code;
		return this;
	}

	public Object getParams() {
		return params;
	}

	public BusinessException setParams(String params) {
		this.params = params;
		return this;
	}

	public String getUserMsg() {
		return userMsg;
	}

	public BusinessException setUserMsg(String userMsg) {
		this.userMsg = userMsg;
		return this;
	}

}
